#ifndef     __CARGO_MOTOR_H
#define     __CARGO_MOTOR_H

#include "../utils/object.h"
#include "../utils/nocopyable.h"
#include "../utils/error.h"

namespace cargo_driver {

class CargoMotor : public Object<CargoMotor>, private NoCopyable {

public:
    void init();

    bool is_alm() const;

    // 400 * 5 * (40 / 26)
    // 12.7 * 50

    Error run_with_row(uint8_t row, uint16_t offset) {
        return run_with_mm((row - 1) * 101.6f + offset);
    }

    void test_run_cw(uint16_t freq);
    void test_run_ccw(uint16_t freq);
    void test_run_stop();

    Error run_with_mm(uint32_t mm) {
        return run( 400 * 10 * 40 * mm / 762 / 26 );
    }

    Error run(uint32_t position);
};

extern CargoMotor cargoMotor;

}


#endif
